package com.qwt.part_time_api.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.qwt.part_time_api.error.BusinessException;
import com.qwt.part_time_api.service.AreaService;
import com.qwt.part_time_api.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 君子慎独
 * @create 2021/12/29 0029 21:00
 */
@RestController
@RequestMapping("/area")
@Api(tags = {"地区列表"})
public class AreaController {

    @Autowired
    private AreaService areaService;

    /**
     * 通过前端定位城市查询数据库存在的 该城市的区县
     *
     * @param region 城市
     * @return 区县
     */
    @GetMapping("/allArea/{region}")
    @ApiOperation(value = "地区列表", notes = "根据城市查询")
    @ApiOperationSupport(author = "Tzeao")
    @ApiResponses(@ApiResponse(code = 200, message = "成功", response = Result.class))
    public Result allArea(@PathVariable("region") String region) throws BusinessException {
        return areaService.findNameList(region);
    }
}
